# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=xxexploiter
pkgver=103.c1f0f41
pkgrel=1
pkgdesc="It generates the XML payloads, and automatically starts a server to serve the needed DTD's or to do data exfiltration."
arch=('any')
groups=('blackarch' 'blackarch-exploitation' 'blackarch-webapp')
url='https://github.com/luisfontes19/xxexploiter'
license=('MIT')
depends=('nodejs' 'npm')
makedepends=('git')
source=("git+https://github.com/luisfontes19/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  npm install && \
    npm run build
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE.txt

  rm -rf *.md LICENSE
  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec node ./dist/cli.js "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

